package baduga.karo;
import java.awt.Toolkit;

//klasa z domyślnym komunikatem wyjścia

/**
 * @author Karolina
 */
public class ExitScreen extends javax.swing.JFrame {

	 
	private static final long serialVersionUID = 1L;
	
	//zmieniamy ikonkę na pasku tytułu
	
    public ExitScreen() {
    	setIconImage(Toolkit.getDefaultToolkit().getImage(ExitScreen.class.getResource("/baduga/karo/resources/icon.png")));
        initComponents();
    }

    //zamykanie okna - z komunikatem żądającym potwierdzenia

    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jButtonYes = new javax.swing.JButton();
        jButtonNo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Badugi - Wyjście");
        setResizable(false);
        
        //dodanie akcji dla poszczególnych przycików
        
        jLabel1.setText("Czy na pewno chcesz wyjść?");

        jButtonYes.setText("Tak");
        jButtonYes.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonYesMouseClicked(evt);
            }
        });

        jButtonNo.setText("Nie");
        jButtonNo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonNoMouseClicked(evt);
            }
        });

        //wygląd okienka
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonYes)
                        .addGap(47, 47, 47)
                        .addComponent(jButtonNo))
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(37, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonYes)
                    .addComponent(jButtonNo))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        pack();
    }

    	//obsługa poszczególnych przycisków
    
    private void jButtonYesMouseClicked(java.awt.event.MouseEvent evt) {
        System.exit(0);
    }

    private void jButtonNoMouseClicked(java.awt.event.MouseEvent evt) {
    	
    	this.dispose();
        
    }

  
    public static void main(String args[]) {
       
    	//zmieniamy styl okienek, jeżeli ten będzie niedostępny ładowany jest domyślny
    	
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ExitScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ExitScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ExitScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ExitScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
       
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new ExitScreen().setVisible(true);
            }
        });
    }

   
    private javax.swing.JButton jButtonNo;
    private javax.swing.JButton jButtonYes;
    private javax.swing.JLabel jLabel1;

}
